package com.jxwifi.cloud.quickclean.assemble;

import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.jxwifi.cloud.quickclean.R;
import com.jxwifi.cloud.quickclean.app.ClientBasicActivity;
import com.jxwifi.cloud.quickclean.app.StateUtils;
import com.jxwifi.cloud.quickclean.bean.RespBaseBean;
import com.jxwifi.cloud.quickclean.utils.ToastUtils;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.view.SuperSwipeRefreshLayout;

import org.simple.eventbus.Subscriber;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class AssembleOrderActivity extends ClientBasicActivity  implements AssembleOrderView{

    @Bind(R.id.rv_assemble_order_list)
    RecyclerView mRvAssembleOrderList;
    @Bind(R.id.rel_list_null)
    RelativeLayout mRelListNull;
    @Bind(R.id.srl_my_assemble_order_list)
    SuperSwipeRefreshLayout mSrlCardRollList;

    private int mPageIndex = 1;//页数
    private int mLimit=10;

    private AssembleOrderPresenter mPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_assemble_order);
        ButterKnife.bind(this);
        openEventBus();
        mPresenter=new AssembleOrderPresenter(mBaseContext,this);
    }

    @OnClick({R.id.rel_img_back_pressed})
    void clickCK(View v){
        switch (v.getId()){
            case R.id.rel_img_back_pressed:
                onBackPressed();
                break;
        }
    }

    @Override
    public void onFailure(int errorCode, String msg) {
        Toast toast = Toast.makeText(mBaseContext, msg, Toast.LENGTH_SHORT);
        ToastUtils.showMyToast(toast, 3000);
    }

    @Override
    public SuperSwipeRefreshLayout getSwip() {
        return mSrlCardRollList;
    }

    @Override
    public int getLimit() {
        return mLimit;
    }

    @Override
    public int getPage() {
        return mPageIndex;
    }

    @Override
    public RelativeLayout getListNull() {
        return mRelListNull;
    }

    @Override
    public RecyclerView getOrderList() {
        return mRvAssembleOrderList;
    }


    @Subscriber(tag = "e-wx-success")
    private void getWXsuccess(RespBaseBean mBean) {
        if (mBean != null) {
            switch (mBean.getTyoe()) {
                case StateUtils.WE_CHAT_SHARE:
                    Toast toast = Toast.makeText(mBaseContext, "分享成功", Toast.LENGTH_SHORT);
                    ToastUtils.showMyToast(toast, 3000);
                    break;
                case StateUtils.WE_CHAT_LOGIN:
                    break;
                case StateUtils.QQ_LOGIN:
                    break;
            }
        }
    }


    @Subscriber(tag = "e-wx-cancel")
    private void getWXcancel(RespBaseBean mBean) {
        if (mBean != null) {
            switch (mBean.getTyoe()) {
                case StateUtils.WE_CHAT_SHARE:
                    Toast toast = Toast.makeText(mBaseContext, "取消分享", Toast.LENGTH_SHORT);
                    ToastUtils.showMyToast(toast, 3000);
                    break;
                case StateUtils.WE_CHAT_LOGIN:
                    break;
                case StateUtils.QQ_LOGIN:
                    break;
            }
        }
    }

    @Subscriber(tag = "e-wx-error")
    private void getWXerror(RespBaseBean mBean) {
        if (mBean != null) {
            switch (mBean.getTyoe()) {
                case StateUtils.WE_CHAT_SHARE:
                    Toast toast = Toast.makeText(mBaseContext, "分享失败", Toast.LENGTH_SHORT);
                    ToastUtils.showMyToast(toast, 3000);
                    break;
                case StateUtils.WE_CHAT_LOGIN:
                    break;
                case StateUtils.QQ_LOGIN:
                    break;
            }
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        mPresenter=new AssembleOrderPresenter(mBaseContext,this);
        mPresenter.initView();
    }
}
